<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: product_parameters.php 135 2013-09-22 07:30:55Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 135 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:30:55 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$module_smarty = new Smarty;
$module_smarty->assign('tpl_path','templates/'.CURRENT_TEMPLATE.'/');
$module_content_display = false;

if($product->data['products_id']) {
	$groups = $db->db_query("SELECT DISTINCT
								g.group_id,
								g.sort_order,
								gd.group_name
                            FROM
								".TABLE_PRODUCTS_PARAMETERS_GROUPS." g,
								".TABLE_PRODUCTS_PARAMETERS_GROUPS_DESCRIPTION ." gd,
								".TABLE_PRODUCTS_PARAMETERS." p
							WHERE
								g.group_id=gd.group_id AND p.group_id=g.group_id
							AND
								p.products_id=".$product->data['products_id']."
							AND
								gd.language_id=".$_SESSION['languages_id']."
							ORDER BY
								g.sort_order");

	if($groups->_numOfRows){
		$module_content_display = true;
		$module_content_group = array();
		$module_content_value = array();

		while(!$groups->EOF) {
			$parameters = $db->db_query("SELECT
											pd.parameters_name,
											pd.parameters_value
										FROM
											".TABLE_PRODUCTS_PARAMETERS." p,
											".TABLE_PRODUCTS_PARAMETERS_DESCRIPTION." pd
										WHERE
											p.parameters_id=pd.parameters_id
										AND
											p.group_id=".$groups['group_id']."
										AND
											p.products_id=".$product->data['products_id']."
										AND
											pd.language_id = ".$_SESSION['languages_id']."
										ORDER BY
											p.sort_order");

			$module_content_group[] = array('GROUPS_NAME' => $groups['group_name']);

			$ii = 0;
			while(!$parameters->EOF){
				$module_content_value[$groups['group_name']][$ii++][$parameters->fields['parameters_name']] = $parameters->fields['parameters_value'];
				$parameters->MoveNext();
			}

			$module_smarty->assign('language', $_SESSION['language']);
			$module_smarty->assign('module_content_display', $module_content_display);
			$module_smarty->assign('module_content_group', $module_content_group);
			$module_smarty->assign('module_content_value', $module_content_value);

			if (USE_CACHE=='false') {
				$module_smarty->caching = false;
				$module= $module_smarty->fetch(CURRENT_TEMPLATE.'/module/product_parameters.html');
			} else {
				$module_smarty->caching = true;
				$module_smarty->cache_lifetime=CACHE_LIFETIME;
				$module_smarty->cache_modified_check=CACHE_CHECK;
				$cache_id = $_SESSION['language'].$_GET['products_id'].$_SESSION['customers_status']['customers_status_name'];
				$module= $module_smarty->fetch(CURRENT_TEMPLATE.'/module/product_parameters.html',$cache_id);
			}
			$info_smarty->assign('MODULE_products_parameters',$module);

			$groups->MoveNext();
		}
		unset($ii);
	}
}
?>